home *** CD-ROM | disk | FTP | other *** search
- Path: mail2news.demon.co.uk!genesis.demon.co.uk
- From: Lawrence Kirby <fred@genesis.demon.co.uk>
- Newsgroups: comp.lang.c
- Subject: Re: [Q]Casting from struct->NULL.
- Date: Fri, 05 Jan 96 21:21:38 GMT
- Organization: none
- Message-ID: <820876898snz@genesis.demon.co.uk>
- References: <DKnDws.FG3.0.sheppard@torfree.net>
- Reply-To: fred@genesis.demon.co.uk
- X-NNTP-Posting-Host: genesis.demon.co.uk
- X-Newsreader: Demon Internet Simple News v1.27
- X-Mail2News-Path: genesis.demon.co.uk
-
- In article <DKnDws.FG3.0.sheppard@torfree.net>
- bh332@freenet.toronto.on.ca "Karim Ladha" writes:
-
- >
- >
- >Re: Casting.
- >
- >How is it possible to cast from a structure to NULL or something
- >equivalent? Currently, I have a function which either returns a
- >structure of type X; pointer, if success or 0L if fail. However,
- >trying to return 0L produces, "... Cannot cast from tagStruct
- >to long..." If you know of a solution, post. Greatly appreciated...
-
- It is rare to pass actual structs as arguments or return values.
- Typically you pass a pointer to a struct. You then have the choice of
- setting it either to point to a struct or to NULL. Since you want the
- struct to exist in the caller once the called function has terminated
- a typical approach is to pass a pointer to a struct as an argument. Your
- called function can then modify the struct through the pointer and return
- a success/failure code in, say, an int return value.
-
- --
- -----------------------------------------
- Lawrence Kirby | fred@genesis.demon.co.uk
- Wilts, England | 70734.126@compuserve.com
- -----------------------------------------
-